package com.vienlien247.vienlien247;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.*;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class TestActivity extends ActionBarActivity {

    @Override

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_test);

//        WebView wv = (WebView) findViewById(R.id.my_webview);
//
//        wv.setWebViewClient(new WebViewClient() {
//
//            @Override
//
//            public boolean shouldOverrideUrlLoading(WebView view, String url) {
//
//                view.loadUrl(url);
//
//                return true;
//
//            }
//
//        });
        //        myWebView.loadData(readTextFromResource(R.raw.buy_minute_form), "text/html", "utf8" );
//        wv.loadUrl("http://www.vienlien247.com");
//        CookieManager.getInstance().setAcceptCookie(true);

        CookieManager.getInstance().setAcceptCookie(true);
        WebView myWebView = (WebView) findViewById(R.id.my_webview);
        myWebView.setWebChromeClient(new WebChromeClient());
        myWebView.loadUrl("http://vienlien247.com");

        myWebView.setBackgroundColor(0x00000000);
        myWebView.getSettings().setLoadsImagesAutomatically(true);
//        CookieManager.getInstance().setAcceptCookie(true);

    }

    private String readTextFromResource(int resourceID) {
        InputStream raw = getResources().openRawResource(resourceID);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        int i;
        try {
            i = raw.read();
            while (i != -1) {
                stream.write(i);
                i = raw.read();
            }
            raw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return stream.toString();
    }
}
